﻿@{
    ViewBag.Title = "Home Page";
}

@Styles.Render("~/Content")
@Scripts.Render("~/JavaScript")
<link href="~/Content/toastr.min.css" rel="stylesheet" />
<script src="~/Scripts/toastr.min.js"></script>
<script src="~/Scripts/jquery.form.js"></script>
<style>
    .form-control {
        padding: 0px;
        font-size: 9px;
        height: 30px;
    }

    #table tr {
        /*height: 45px;*/
    }

    #table td {
        padding: 3px;
    }

    #table th {
        font-size: 6px;
        padding: 3px;
    }

    #list .panel-body {
        padding: 10px;
    }

    .list-group-item {
        min-height: 45px;
        padding: 3px 5px;
    }

    .list-group-item-heading {
        margin-top: 0px;
        font-size: 9px;
    }

    .list-group-item-text {
        margin-bottom: 0px;
    }

    #tbInfo td {
        width: 120px;
    }

    #tbInfo th {
        width: 120px;
        font-size: 11px;
    }

    #tbInfo input {
        width: 140px;
        font-size: 10px;
    }

    .vlad {
        font-size: 9px !important;
    }
    /*.tbInfo td {
        width: 120px;
    }
    .tbInfo td {
        width: 120px;
    }*/
    .w30 {
        width: 30px;
    }

    .w40 {
        width: 40px;
    }

    .w50 {
        width: 50px;
    }

    .w60 {
        width: 60px;
    }

    .w80 {
        width: 80px;
    }

    .w95 {
        width: 95px;
    }

    .w120 {
        width: 120px;
    }

    .btn {
        padding: 1px 6px;
    }
    .ace_print-margin {
        width: 0px !important;
    }
</style>
<div class="container-fluid" id="app" style="font-size:9px;height:calc(100% - 10px);">
    <div class="tabs-container" style="height:calc(100% - 65px);">

        <ul class="nav nav-tabs" id="menutab">
            <li class="" data-id="configset">
                <a data-toggle="tab" href="#tab-0" aria-expanded="false">Config</a>
            </li>
            <li class="active">
                <a data-toggle="tab" href="#tab-1" aria-expanded="true"> Main</a>
            </li>
            <li class="">
                <a data-toggle="tab" href="#tab-2" aria-expanded="false">Entity</a>
            </li>
            <li class="">
                <a data-toggle="tab" href="#tab-2dto" aria-expanded="false">Dto</a>
            </li>
            @*<li class="">
                    <a data-toggle="tab" href="#tab-10" aria-expanded="false">Dal</a>
                </li>*@
            <li class="">
                <a data-toggle="tab" href="#tab-5" aria-expanded="false">AppService</a>
            </li>
            <li class="">
                <a data-toggle="tab" href="#tab-Interface" aria-expanded="false">Interface</a>
            </li>
            <li class="">
                <a data-toggle="tab" href="#tab-4" aria-expanded="false">Controller</a>
            </li>
            <li class="">
                <a data-toggle="tab" href="#tab-6" aria-expanded="false">Edit Html</a>
            </li>
            <li class="">
                <a data-toggle="tab" href="#tab-7" aria-expanded="false">Edit JS</a>
            </li>
            <li class="">
                <a data-toggle="tab" href="#tab-8" aria-expanded="false">List Html</a>
            </li>
            <li class="">
                <a data-toggle="tab" href="#tab-9" aria-expanded="false">List JS</a>
            </li>
            <li class="">
                <a data-toggle="tab" href="#tab-3" aria-expanded="false">Add Table SQL</a>
            </li>
            @*<li class="">
                    <a data-toggle="tab" href="#tab-11" aria-expanded="false">ViewData Entity</a>
                </li>*@
            @*<li class="">
                    <a data-toggle="tab" href="#tab-12" aria-expanded="false">Build Menu SQl</a>
                </li>*@
        </ul>
        <div class="row" style="height: calc(100% - 35px);">
            <div id="container" class="col-lg-2" style="margin-top: 10px;">
                <div style="height:100%;">
                    <div id="wrap" style="height:100%;">
                        <div class="product-head">
                            <div id="form">
                                <div class="input-group">
                                     <input id="txtSearch" type="text" class="filterinput form-control" placeholder="Search for...">
                                    <span class="input-group-btn" style="top:-1px;">
                                        <button class="btn btn-primary btn-sm glyphicon glyphicon-repeat" type="button" onclick="refreshList();"><span class="" aria-hidden="true"></span></button>
                                    </span>
                                </div>
                            </div>
                            <div class="clear"></div>
                        </div>
                        <div class="list-group" id="listTable" style="height:calc(100% - 35px);overflow-x:hidden;margin-bottom: 0px;">
                            <a v-for="(data,index) in tableList" class="list-group-item" :TableName="data.TableName" v-on:click="getTableInfo(data.TableName,data.Comment,$event)">
                                <input type="checkbox" class="css-checkbox sme" :id="'lck-9-'+index" v-model="data.IsChecked">
                                <label :for="'lck-9-'+index" class="css-label sme vlad" style="margin-bottom:0px;"></label>
                                <h4 class="list-group-item-heading">{{data.TableName}}</h4>
                                <span class="badge">{{data.FieldCount}}</span>
                                <p class="list-group-item-text">{{data.Comment}}</p>

                            </a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-lg-10">
                <div class="tab-content" style="height:100%;">
                    <div id="tab-0" class="tab-pane " style="height:100%;padding-top:10px;">
                        <div class="panel panel-default">
                            <div class="panel-body">
                                <div class="row">
                                    <span class="input-group">
                                        <span class="input-group-addon">
                                            <input type="radio" name="DataSource" aria-label="...">
                                            <label>数据库</label>
                                        </span>
                                        <select id="DataType" class="form-control" style="width:100px;" onchange="changeDataType()">
                                            <option value="Oracle" selected data-provider="System.Data.OracleClient">Oracle</option>
                                            <option value="SqlServer" data-provider="System.Data.SqlClient">SqlServer</option>
                                        </select>
                                        <select id="selListConnection" class="form-control" style="width:500px;" onchange="changeConnect()"></select>
                                        <input type="text" class="form-control" style="width:481px;margin-left:-500px;" id="connection" value="" placeholder="连接字符串">
                                        <input type="text" class="form-control" style="width:120px;margin-left:10px;" id="dataBaseName" value="" placeholder="数据库名称">
                                        <input type="button" class="btn btn-primary" style="margin-left:10px;" value="测试连接" onclick="checkConnect();" />
                                        <input type="button" class="btn btn-primary" style="margin-left:10px;" value="确定" onclick="setConnect();" />
                                    </span>
                                    </div>
                            </div>
                        </div>
                        <div class="panel panel-default">
                            <div class="panel-body">
                                <div class="row" style="padding-top:10px;">
                                    <div class="input-group">
                                        <span class="input-group-addon">
                                            <input type="radio" name="DataSource" aria-label="...">
                                            <label>PDM</label>
                                        </span>
                                        <form id="uploadfie" method="post" enctype="multipart/form-data" style="float:left;">
                                            <input type="file" name="pdmFile" class="file" id="pdmFile" style="margin-bottom:0px;" />
                                        </form>
                                        <input type="button" class="btn btn-primary" style="margin-left:10px;"  value="上传" onclick="fileSubmit();" />
                                        <input type="button" class="btn btn-primary" style="margin-left:10px;"  id="btnRefresh" onclick="refresh();" value="刷新" />
                                    </div>
                                </div>
                            </div>
                        </div>
                        <br />
                    </div>
                    <div id="tab-1" class="tab-pane active" style="height:100%;">
                        <div class="panel-body" style="height:100%;">
                            <div class="row" style="height:100%;">
                                <div class="col-lg-12" style="height:100%;">
                                    <div class="form-inline">
                                        <div class="form-group">
                                            <label for="txtTableName">TableName</label>
                                            <input type="text" class="form-control" id="txtTableName">
                                        </div>
                                        <div class="form-group">
                                            <label for="txtTableComment">TableComment</label>
                                            <input type="text" class="form-control" id="txtTableComment">
                                        </div>
                                    </div>
                                    <table id="table" class="table" style="font-size:9px;margin-bottom:0px;table-layout:fixed;">
                                        <thead>
                                            <tr>
                                                <th class="w50">操作</th>
                                                <th class="w30">
                                                    <input id="checkbox0" type="checkbox" class="css-checkbox lrg">
                                                    <label for="checkbox0" class="css-label lrg vlad" style="margin-bottom:0px;"></label>
                                                </th>
                                                <th style="width:140px;"><div class="input-group m-b" style="margin-bottom:0px;">字段</div></th>
                                                <th class="w120">属性</th>
                                                <th class="w120">注释</th>
                                                <th class="w95">类型</th>
                                                <th class="w60">长度</th>
                                                <th class="w40">非空</th>
                                                <th class="w60">默认值</th>
                                                <th width="40%">各项配置</th>
                                            </tr>
                                        </thead>
                                    </table>

                                    <div class="ibox" style="height:calc(100% - 28px);overflow:auto;">
                                        <table id="table" class="table" style="font-size:9px;table-layout:fixed;">
                                            <tr v-for="(info,index) in fieldList">
                                                <td class="w50">
                                                    <span class="glyphicon glyphicon-fullscreen" aria-hidden="true" v-on:click="appendRow(index)"></span>
                                                    <span class="glyphicon glyphicon-plus" aria-hidden="true" v-on:click="addRow(index)"></span>
                                                    <span class="glyphicon glyphicon-minus" aria-hidden="true" v-on:click="delRow(index)"></span>
                                                </td>
                                                <td class="w30">
                                                    <input :id="'ck-1-'+index" type="checkbox" class="css-checkbox lrg" v-model="info.IsCheck">
                                                    <label :for="'ck-1-'+index" class="css-label lrg vlad" style="margin-bottom:0px;"></label>
                                                </td>
                                                <td style="width:140px;">
                                                    <div class="input-group m-b" style="margin-bottom:0px;">
                                                        @*<span class="input-group-addon" style="padding-bottom: 0px;padding-left: 6px;padding-right: 2px;padding-top: 0px;">
                                                    <input type="checkbox" class="css-checkbox lrg" :id="'ck-9-'+index" v-model="info.IsDataColumn">
                                                    <label :for="'ck-9-'+index" class="css-label lrg vlad" style="margin-bottom:0px;"></label>
                                                </span>*@
                                                        <input type="text" class="form-control" v-model="info.ColumnName">
                                                    </div>
                                                </td>
                                                <td class="w120"><input type="text" class="form-control" v-model="info.PropertyName"></td>
                                                <td class="w120"><input type="text" class="form-control" v-model="info.Comment"></td>
                                                <td class="w95"><input type="text" class="form-control SelectType" v-model="info.TypeName"></td>
                                                <td class="w60"><input type="text" class="form-control form-control-sm" v-model="info.MaxLength"></td>
                                                <td class="w40">
                                                    <input :id="'ck-2-'+index" type="checkbox" class="css-checkbox lrg" v-model="info.NotNUll">
                                                    <label :for="'ck-2-'+index" class="css-label lrg vlad" style="margin-bottom:0px;"></label>
                                                </td>
                                                <td class="w60"><input type="text" class="form-control" v-model="info.DefaultValue"></td>
                                                <td width="40%">
                                                    <input :id="'ck-3-'+index" type="checkbox" class="css-checkbox lrg" v-model="info.IsValidate">
                                                    <label :for="'ck-3-'+index" class="css-label lrg vlad" style="margin-bottom:0px;">必填</label>
                                                    <input :id="'ck-6-'+index" type="checkbox" class="css-checkbox lrg" v-model="info.IsShow">
                                                    <label :for="'ck-6-'+index" class="css-label lrg vlad" style="margin-bottom:0px;">列表展示</label>
                                                    <input :id="'ck-7-'+index" type="checkbox" class="css-checkbox lrg" v-model="info.IsCondition">
                                                    <label :for="'ck-7-'+index" class="css-label lrg vlad" style="margin-bottom:0px;">搜索条件</label>
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div id="tab-2" class="tab-pane" style="height:100%;">
                        <div class="panel-body" style="height:100%;">
                            <div class="form-inline">
                                <div class="form-group">
                                    <div class="input-group">
                                        <div class="input-group-addon">EntityName</div>
                                        <input type="text" class="form-control" id="txtEntityName" placeholder="EntityName">
                                    </div>
                                </div>
                                <button type="submit" class="btn btn-primary" onclick="setData('BuildEntity');" id="btnBuildEntity">Build Code</button>
                            </div>
                            <div>
                                <div id="EditorBuildEntity" style="height:100%;margin-top:15px;"></div>
                            </div>
                        </div>
                    </div>
                    <div id="tab-2dto" class="tab-pane" style="height:100%;">
                        <div class="panel-body" style="height:100%;">
                            <div class="form-inline">
                                @*<div class="form-group">
                            <div class="input-group">
                                <div class="input-group-addon">EntityName</div>
                                <input type="text" class="form-control" id="txtEntityName" placeholder="EntityName">
                            </div>
                        </div>*@
                                <button type="submit" class="btn btn-primary" onclick="setData('BuildDto');" id="btnBuildDto">Build Code</button>
                            </div>
                            <div>
                                <div id="EditorBuildDto" style="height:100%;margin-top:15px;"></div>
                            </div>
                        </div>
                    </div>
                    <div id="tab-3" class="tab-pane" style="height:100%;">
                        <div class="panel-body" style="height:100%;">
                            <button class="btn-success" onclick="setData('CreateTable');" id="btnCreateTable">CreateTable</button>
                            <div>
                                <div id="EditorCreateTable" style="height:100%;margin-top:15px;"></div>
                            </div>
                        </div>
                    </div>
                    <div id="tab-4" class="tab-pane" style="height:100%;">
                        <div class="panel-body" style="height:100%;">
                            <button class="btn-success" onclick="setData('BuildController');">BuildController</button>
                            <div>
                                <div id="EditorBuildController" style="height:100%;margin-top:15px;"></div>
                            </div>
                        </div>
                    </div>
                    <div id="tab-5" class="tab-pane" style="height:100%;">
                        <div class="panel-body" style="height:100%;">
                            <button class="btn-success" onclick="setData('BuildBLL');">BuildService</button>
                            <div>
                                <div id="EditorBuildBLL" style="height:100%;margin-top:15px;"></div>
                            </div>
                        </div>
                    </div>
                    <div id="tab-Interface" class="tab-pane" style="height:100%;">
                        <div class="panel-body" style="height:100%;">
                            <button class="btn-success" onclick="setData('BuildInterface');">BuildInterface</button>
                            <div>
                                <div id="EditorBuildInterface" style="height:100%;margin-top:15px;"></div>
                            </div>
                        </div>
                    </div>
                    <div id="tab-6" class="tab-pane" style="height:100%;">
                        <div class="panel-body" style="height:100%;">
                            <div class="form-inline">
                                @*<div class="form-group">
                            <div class="input-group">
                                <div class="input-group-addon">ModelFolderName</div>
                                <input type="text" class="form-control" id="txtModelFolderName" placeholder="ModelFolderName">
                            </div>
                        </div>*@
                                <button class="btn-success" onclick="setData('BuildEditHTML');" id="btnBuildEditHTML">Build Code</button>
                            </div>
                            <div>
                                <div id="EditorBuildEditHTML" style="height:100%;margin-top:15px;"></div>
                            </div>
                        </div>
                    </div>
                    <div id="tab-7" class="tab-pane" style="height:100%;">
                        @*edit js*@
                        <div class="panel-body" style="height:100%;">
                            <button class="btn-success" onclick="setData('BuildEditJS');">Build Code</button>
                            <div>
                                <div id="EditorBuildEditJS" style="height:100%;margin-top:15px;"></div>
                            </div>
                        </div>
                    </div>
                    <div id="tab-8" class="tab-pane" style="height:100%;">
                        <div class="panel-body" style="height:100%;">
                            <button class="btn-success" onclick="setData('BuildListHtml');">Build Code</button>
                            <div>
                                <div id="EditorBuildListHtml" style="height:100%;margin-top:15px;"></div>
                            </div>
                        </div>
                        @*List HTML*@
                    </div>
                    <div id="tab-9" class="tab-pane" style="height:100%;">
                        <div class="panel-body" style="height:100%;">
                            <div class="form-inline">
                                @*<div class="form-group">
                            <div class="input-group">
                                <div class="input-group-addon">PageName</div>
                                <input type="text" class="form-control" id="txtPageName" placeholder="PageName">
                            </div>
                        </div>*@
                                <button class="btn-success" onclick="setData('BuildListJS');">Build Code</button>
                            </div>
                            <div>
                                <div id="EditorBuildListJS" style="height:100%;margin-top:15px;"></div>
                            </div>
                        </div>
                    </div>
                    
                </div>

            </div>
        </div>
        
    </div>
</div>
<script>
    var dicConnection = @Html.Raw(Json.Encode(Model));
    $(function () {
        var height = document.documentElement.clientHeight;
        document.getElementsByTagName('body')[0].style.height = height;
        $('#container').height(height - 10);
        toastr.options = {
            "closeButton": true,
            "debug": false,
            "progressBar": true,
            "positionClass": "toast-top-right",
            "onclick": null,
            "showDuration": "1000",
            "hideDuration": "20",
            "timeOut": "5000",
            "extendedTimeOut": "20",
            "showEasing": "swing",
            "hideEasing": "linear",
            "showMethod": "fadeIn",
            "hideMethod": "fadeOut"
        }
    });

    window.onresize = function () {
        var height = document.documentElement.clientHeight;
        document.getElementsByTagName('body')[0].style.height = height;
    }
    
</script>
<script src="~/Scripts/ace/ace.js"></script>
<script src="~/Scripts/ace/ext-language_tools.js"></script>